package br.com.OnFit.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.OnFit.entidades.Usuario;
import br.com.OnFit.jdbc.UsuarioDAO;

@WebServlet("/usercontroller.do")
public class UsuarioController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public UsuarioController() {
        super();

    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			//String sexo = request.getParameter("sexo");
			//System.out.println("sexo: " + sexo);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//	System.out.println("Post chegou");
		
		String login = request.getParameter("usuarioLogin");
		String senha = request.getParameter("usuarioSenha");
		
		Usuario usuario = new Usuario();
		usuario.setLogin(login);
		usuario.setSenha(senha);
		
		UsuarioDAO usuDao = new UsuarioDAO();
		usuDao.Cadastrar(usuario);
		
		PrintWriter mostrarBrowser = response.getWriter();
		mostrarBrowser.println("Cadastrado com sucesso!");
		
	}

}
